package net.siit.datatype;

/**
 * Triplet data structure
 * source, link, target
 * 
 * @author arthit
 */
public class Triplet implements Comparable {
    public String src = null;
    public String lnk = null;
    public String trg = null;
    
    public Triplet(String src, String lnk, String trg) {
        this.src = src;
        this.lnk = lnk;
        this.trg = trg;
    }
    
    @Override
    public int compareTo(Object o) {
        if (Triplet.class != o.getClass())
            throw new UnsupportedOperationException("Not supported yet.");
        
        Triplet t = (Triplet) o;
        
        if ( ( ((src == null) && (t.src == null)) || src.equals(t.src) ) &&
             ( ((trg == null) && (t.trg == null)) || trg.equals(t.trg) ) &&
             ( ((lnk == null) && (t.lnk == null)) || lnk.equals(t.lnk) ) ) 
            return 0;
        
        return -1;
    }
    
    @Override
    public boolean equals(Object o) {
        try {
            if (this.compareTo(o) == 0)
                return true;
        } catch (UnsupportedOperationException e) {
            return false;
        }
        return false;
    }

    public int hashCode() {
        int hash = 3;
        hash = 79 * hash + this.src != null ? this.src.hashCode() : 0;
        hash = 79 * hash + this.lnk != null ? this.lnk.hashCode() : 0;
        hash = 79 * hash + this.trg != null ? this.trg.hashCode() : 0;
        return hash;
    }
}
